package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.SystemCall;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IAdvertisementService;
import cn.wolfcode.trip.base.service.ISystemCallService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("advertisement")
public class AdvertisementController {

    @Autowired
    private IAdvertisementService advertisementService;
    @Autowired
    private ISystemCallService systemCallService;

    @RequestMapping("list")
    public String list(QueryObject qo,Model model){
        PageInfo info=advertisementService.query(qo);
        model.addAttribute("pageInfo",info);
        return "advertisement/list";
    }

    @RequestMapping("addMycomment")
    @ResponseBody
    public JsonResult save(SystemCall systemCall){
        Long[] ids = systemCallService.selectAllUserId();
        for (Long id : ids) {
            systemCall.setUserId(id);
            systemCallService.insert(systemCall);
        }
        return new JsonResult();
    }

}